﻿package;

enum Color {
    RGB (r : Int, g : Int, b : Int);
    BLACK;
    WHITE;
    /*
     
     
    public static function add (c1 : Color, c2 : Color) {
        return
        switch ( c1, c2 ) {
            case RGB(r1, g1, b1) : RGB(r2, g2, b2)  : RGB(r1 + r2, g1 + g2, b1 + b2); // matches if both colors are RGB
            case BLACK : _                          : c2;                             // matches if first color is BLACK
            case _ : BLACK                          : c1;                             // matches if second color is BLACK
            case WHITE : _, _ : WHITE               : WHITE                           // matches if one color is WHITE
        }
    }
    
    alternative syntax
    
    public static function add (c1 : Color, c2 : Color) {
        return
        switch ( c1, c2 ) {
            case ( RGB(r1, g1, b1), RGB(r2, g2, b2) ) : RGB(r1 + r2, g1 + g2, b1 + b2); // matches if both colors are RGB
            case ( BLACK , _ )                        : c2;                             // matches if first color is BLACK
            case (_ , BLACK)                          : c1;                             // matches if second color is BLACK
            case ( WHITE , _ ), (_ , WHITE)           : WHITE                           // matches if one color is WHITE
        }
    }
    
    
    public static function add (c1 : Color, c2 : Color) {
        switch ( c1 ) {
            case RGB(r1, g1, b1) : switch (c2) {
                                        case RGB(r2, g2, b2): RGB(r1 + r2, g1 + g2, b1 + b2);
                                        case BLACK : c1
                                        case WHITE: WHITE;
                                        
                                    }
            case BLACK : c2;
            case WHITE : WHITE;

        }
    }
    */
    
}



class MyTest {
    
    
    
    
    public static function main() : Void 
    {
        
        var f = function (a : String) return a;
        
        trace(Type.typeof(f));
        
        
        //new MyTest();
    }
    
}
